package com.enjoyor.soa.traffic.server.efoms.dubbo.manage;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.enjoyor.soa.traffic.api.dto.efoms.CheckRecodeInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.DeviceFaultCollectInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.DeviceNowCollectSumDto;
import com.enjoyor.soa.traffic.api.dto.efoms.DeviceUnnormalCollectInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.OppmWorkCollectInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.RepairsInfoDto;
import com.enjoyor.soa.traffic.core.efoms.domain.CheckRecodeInfo;
import com.enjoyor.soa.traffic.core.efoms.domain.DeviceFaultCollectInfo;
import com.enjoyor.soa.traffic.core.efoms.domain.DeviceNowCollectSum;
import com.enjoyor.soa.traffic.core.efoms.domain.DeviceUnnormalCollectInfo;
import com.enjoyor.soa.traffic.core.efoms.domain.OppmWorkCollectInfo;
import com.enjoyor.soa.traffic.core.efoms.domain.RepairsInfo;
import com.enjoyor.soa.traffic.core.efoms.service.ISurveyDeviceCollectInfoService;
import com.enjoyor.soa.traffic.util.helper.ReflectHelper;
import com.enjoyor.soa.traffic.util.helper.ResultHelper;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

@Service(timeout = 6000)
public class ManageSurveyDeviceCollectInfoService {
	
	@Autowired
	private ISurveyDeviceCollectInfoService surveyDeviceCollectInfoService;
	
	public ResultPojo getDeviceUnnormalCollectInfoList(String devTypeCode){
		Map<String, Object> resultMap = surveyDeviceCollectInfoService.getDeviceUnnormalCollectInfoList(devTypeCode);
		List<DeviceUnnormalCollectInfo> list = (List<DeviceUnnormalCollectInfo>) resultMap.get("list");
		resultMap.put("list", ReflectHelper.listToList(list, DeviceUnnormalCollectInfoDto.class));
		return ResultHelper.getResult(resultMap);
	}
	
	public ResultPojo getDeviceUnNorForArea(String devTypeCode){
		List<DeviceUnnormalCollectInfo> list = surveyDeviceCollectInfoService.getDeviceUnNorForArea(devTypeCode);
		return ResultHelper.getResult(ReflectHelper.listToList(list, DeviceUnnormalCollectInfoDto.class));
	}
	
	public ResultPojo getDeviceNowCollectSum(String beginTime,String endTime,String devTypeCode){
		List<DeviceNowCollectSum> list = surveyDeviceCollectInfoService.getDeviceNowCollectSum(beginTime, endTime,devTypeCode);
		return ResultHelper.getResult(ReflectHelper.listToList(list, DeviceNowCollectSumDto.class)); 
	}
	
	public ResultPojo getCheckCountForDeptIdAndSum(){
		Map<String, Object> resultMap = surveyDeviceCollectInfoService.getCheckCountForDeptIdAndSum();
		List<CheckRecodeInfo> list = (List<CheckRecodeInfo>)resultMap.get("list");
		resultMap.put("list", ReflectHelper.listToList(list, CheckRecodeInfoDto.class));
		return ResultHelper.getResult(resultMap);
	}
	
	public ResultPojo getRepCountForDeptIdAndSum(){
		Map<String, Object> resultMap = surveyDeviceCollectInfoService.getRepCountForDeptIdAndSum();
		List<RepairsInfo> list = (List<RepairsInfo>)resultMap.get("list");
		resultMap.put("list", ReflectHelper.listToList(list, RepairsInfoDto.class));
		return ResultHelper.getResult(resultMap);
	}
	
	public ResultPojo getRepSourceCount(String devTypeCode) {
		// TODO Auto-generated method stub
		List<RepairsInfo> list = surveyDeviceCollectInfoService.getRepSourceCount(devTypeCode);
		return ResultHelper.getResult(ReflectHelper.listToList(list, RepairsInfoDto.class));
	}
	
	public ResultPojo getRepSourceCountForDept(String devTypeCode) {
		// TODO Auto-generated method stub
		List<RepairsInfo> list = surveyDeviceCollectInfoService.getRepSourceCountForDept(devTypeCode);
		return ResultHelper.getResult(ReflectHelper.listToList(list, RepairsInfoDto.class));
	}
	
	public ResultPojo getFaultCollectReal(String devTypeCode){
		List<DeviceUnnormalCollectInfo> list = surveyDeviceCollectInfoService.getFaultCollectReal(devTypeCode);
		return ResultHelper.getResult(ReflectHelper.listToList(list, DeviceUnnormalCollectInfoDto.class));
	}
	
	public ResultPojo getFaultCollectRealTrend(String devTypeCode, String beginTime,
			String endTime){
		List<DeviceUnnormalCollectInfo> list = surveyDeviceCollectInfoService.getFaultCollectRealTrend(devTypeCode, beginTime, endTime);
		return ResultHelper.getResult(ReflectHelper.listToList(list, DeviceUnnormalCollectInfoDto.class));
	}
	
	/**
	 * 获取所有设备类型的故障数量；
	 * @return
	 */
	public ResultPojo selectDeviceFaultCollectInfoList(String devTypeCode){
		Map<String, Object> resultMap = surveyDeviceCollectInfoService.selectDeviceFaultCollectInfoList(devTypeCode);
		List<DeviceFaultCollectInfo> list = (List<DeviceFaultCollectInfo>) resultMap.get("list");
		resultMap.put("list", ReflectHelper.listToList(list, DeviceFaultCollectInfoDto.class));
		return ResultHelper.getResult(resultMap);
	}
	
	/**
	 * 根据设备编号获取对应类型设备的故障数量
	 */
	public ResultPojo selectDeviceFaultCollectByDevTypeCode(String devTypeCode){
		List<DeviceFaultCollectInfo> list = surveyDeviceCollectInfoService.selectDeviceFaultCollectByDevTypeCode(devTypeCode);
		return ResultHelper.getResult(ReflectHelper.listToList(list, DeviceFaultCollectInfoDto.class));
	}
	
	/**
	 * 根据部门进行故障数量统计分组
	 * @param devTypeCode
	 * @return
	 */
	public ResultPojo selectDevFaColGroupByDepId(String devTypeCode){
		List<DeviceFaultCollectInfo> list = surveyDeviceCollectInfoService.selectDevFaColGroupByDepId(devTypeCode);
		return ResultHelper.getResult(ReflectHelper.listToList(list, DeviceFaultCollectInfoDto.class));
	}
	
	public ResultPojo selectOppmWorkCollectInfoList(String devTypeCode){
		List<OppmWorkCollectInfo> list = surveyDeviceCollectInfoService.selectOppmWorkCollectInfoList(devTypeCode);
		return ResultHelper.getResult(ReflectHelper.listToList(list, OppmWorkCollectInfoDto.class));
	}
	
	public ResultPojo getWarningCountForToday(String devTypeCode){
		Map<String, Object> resultMap = surveyDeviceCollectInfoService.getWarningCountForToday(devTypeCode);
		return ResultHelper.getResult(resultMap);
	}

}
